home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
- #
- # Copyright 2002, Silicon Graphics, Inc.
- # All Rights Reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # ---------------
- # convert_helpmap
- # ---------------
- # syntax:
- #
- # convert_helpmap <bkshlf> <bk> <toc_file> <helpmap_file>
- #
-
- $SHLF = $ARGV[0];
- $BK = $ARGV[1];
- $TOC = $ARGV[2];
- $HMAP = $ARGV[3];
-
- if ($SHLF eq '' || $BK eq '' || $TOC eq '' || $HMAP eq '') {
- &usage("bookshlf, book, toc_file, or helpmap_file not specified");
- }
- if (!(-f $TOC) || !(-f $HMAP)) {
- &usage("TOC file (${TOC}) or helpmap file (${HMAP}) not found");
- }
-
- my(@hl, @pts) = ();
- my(%toc_pts) = ();
- my($f, $s) = '';
-
- # open existing helpmap, read in all points
- #
- open(HELPMAP, "${HMAP}") || &usage("Cannot open helpmap: ${HMAP}");
- @hl = <HELPMAP>;
- close(HELPMAP);
-
-
- # open toc file, get new points
- #
- my($help_fnd) = 0;
- open(TOCF, "${TOC}") || &usage("Cannot open TOC: ${TOC}");
- while(<TOCF>) {
-
- chop;
-
- if ($help_fnd == 0) {
- if ($_ =~ /^\#[\s]+help/i) {
- $help_fnd = 1;
- }
- next;
- }
-
- @pts = split(/\|/, $_);
- if ($pts[3] ne '' && $pts[2] ne '') {
- $toc_pts{$pts[3]} = $pts[2];
- }
- }
- close(TOCF);
-
-
- # open new/revised helpmap which we will write to
- #
- open(HM_REV, "> ${HMAP}.rev") || &usage("Cannot open helpmap: ${HMAP}.rev");
-
- # check helpmap points
- #
- foreach $s (@hl) {
-
- if ($s !~ /\;/ || $s =~ /^\#/ || length($s) <= 1) {
- print HM_REV $s;
- next;
- }
-
- @pts = split(/\;/, $s);
-
- if ($pts[1] =~ /^HREF/i) {
- print HM_REV $s;
- next;
- }
-
- if (($f = $toc_pts{$pts[4]}) ne '') {
- $pts[1] = "HREF=file:/usr/share/Insight/library/SGI_bookshelves/" .
- "${SHLF}/books/${BK}/sgi_html/${f}";
-
- print HM_REV join(';', @pts);
- }
- }
- close(HM_REV);
- print "\nconvert_helpmap: revised helpmap - ${HMAP}.rev\n";
-
- exit 0;
-
-
- sub usage {
-
- my($err) = @_;
- print "\nusage: convert_helpmap <bkshlf> <bk> <toc_file> <helpmap_file>\n",
- ($err ne '' ? "${err}\n" : '');
- exit(-1);
- }
-
-